package currying;

/**
 * @Description: 函数柯里化
 * @Author: tfq
 * @Date: 2025-02-10 21:22
 */
public class Currying0Test {

    @FunctionalInterface
    interface F2 {
        int operate(int a, int b);
    }

    @FunctionalInterface
    interface Fa {
        Fb operate(int a);
    }

    @FunctionalInterface
    interface Fb {
        int operate(int b);
    }

    public static void main(String[] args) {
        //两个参数的函数对象
        F2 f2 = (a, b) -> a + b;
        System.out.println("两个参数的函数对象结果："+f2.operate(1, 2));

        /**
         * 改造两个参数的函数对象，变成一个返回函数对象的函数对象
         * (a) -> 返回另一个函数对象
         *        (b) -> a+b
         */
        Fa fa = a -> b -> a + b;
        Fb fb =fa.operate(1);
        int res = fb.operate(2);
        System.out.println("1个参数的函数对象结果："+res);
    }
}